<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
	<%String path = request.getContextPath(); %> 
<!DOCTYPE html >
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
	<link rel="shortcut icon" href="favicon.ico">
     
	<link href="../plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    
    <link href="../plugins/summernote/summernote.css" rel="stylesheet">
    <link href="../plugins/summernote/summernote-bs3.css" rel="stylesheet">
	
	<!-- 全局js -->
    <script src="../rec/js/jquery-1.8.3.min.js"></script>
    <script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
	<script src="js/async-ajax.js"></script>
    <script type="text/javascript">
    	var bloglist = "";
    
    	var bloglistHtml = "";
    	/* $(function(){
    		
    		var result =  doGet("getBlogContent", "");
    		bloglist = result.detail.bloglist;
    		
    		$.each(bloglist, function(i,obj){ 
    			bloglistHtml += "<tr id='"+obj.serial_id+"' name='"+JSON.stringify(obj)+"'><td class='project-status'><span class='label label-primary'>进行中</span></td><td class='project-title'><a >"+obj.blog_title+"</a><br><small>创建于 2014.08.15</small></td><td class='project-completion'><span>"+obj.type_name+"</span></div></div></td><td class='project-completion'><span>"+obj.user_name+"</span></div></div></td><td class='project-completion'><span>"+obj.update_time+"</span></div></div></td><td class='project-actions'><a class='btn btn-white btn-sm'><i class='fa fa-folder'></i> 查看</a> <a class='btn btn-white btn-sm' onclick='open_from_editor("+obj.serial_id+")'><i class='fa fa-pencil'></i> 编辑</a></td></tr>";
  			});
    		
    		$("#bloglist").empty();
    		$("#bloglist").append(bloglistHtml);
    	}) */
    	
  		function open_from_editor( id ) {
    		if(id!=null && id!=""){
    			var obj = $("#"+id).attr("name");
    			console.log(""+obj);
    			obj = JSON.parse(obj);
    			$("#blogTitle").val(obj.blog_title);
    			$("#blogContent").val(obj.blog_content);
    			$('#b_content').code(obj.blog_content); 
    		}
	         $('#myModal5').modal('show');
	         $("#model_hide").attr("style" , "display:none");
	    }
    
    	function findBlogByTypeNo(typeNo){
    		alert(typeNo);
    	}
    
    </script>
    
</head>
<body class="gray-bg">

    <div class="wrapper wrapper-content animated fadeInUp" >
        <div class="row">
        	<div class="col-sm-3">
        		<div class="ibox">
        			<div class="ibox-title">
	        			<h5>分类</h5>
                    </div>
	        		<div class="ibox-content">
	        			<button class="btn btn-primary btn-block">新建分类</button>
	        			<div class="hr-line-dashed"></div>
	                    <ul class="folder-list" style="padding: 0">
	                    
	                    
	                    		<c:forEach items="${typelist }" var="obj" >
	                                <li>
	                                	<a onclick="findBlogByTypeNo(${obj.type_no})"><i class="fa fa-folder"></i> ${obj.type_name } <span class="label label-warning pull-right">${obj.num }</span></a>
	                                </li>
	                    		</c:forEach>
                         </ul>
                 	</div>
        		</div>
        	</div>
            <div class="col-sm-9">
                <div class="ibox">
                    <div class="ibox-title">
                        <h5>所有项目</h5>
                        <div class="ibox-tools">
                        	<!-- data-toggle="modal" data-target="#myModal5" -->
                            <a  class="btn btn-primary btn-xs" onclick="open_from_editor();"  >撰写博文</a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row m-b-sm m-t-sm">
                            <div class="col-md-1">
                                <button type="button" id="loading-example-btn" class="btn btn-white btn-sm"><i class="fa fa-refresh"></i> 刷新</button>
                            </div>
                            <div class="col-md-11">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入博文名称" class="input-sm form-control"> <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                            </div>
                        </div>
                        <div class="project-list">

                            <table class="table table-hover">
                                <tbody id="bloglist">
                                	<c:forEach  items="${bloglist.list }"  var="obj" varStatus="i"   >
		                                	<tr  id="${obj.serial_id }">
		                                        <td class="project-status">
		                                            <span class="label label-primary">进行中
		                                        </span></td>
		                                        <td class="project-title">
		                                            <a >${obj.blog_title}</a>
		                                            <br>
		                                        </td>
		                                        
		                                        <td class="project-people">
		                                                <small>${obj.type_name}</small>
		                                        </td>
		                                        <td class="project-people">
		                                                <small>${obj.user_name}</small>
		                                        </td>
		                                        <td class="project-people">
		                                            <a href="projects.html"><img alt="image" class="img-circle" src="img/a3.jpg"></a>
		                                            <a href="projects.html"><img alt="image" class="img-circle" src="img/a1.jpg"></a>
		                                            <a href="projects.html"><img alt="image" class="img-circle" src="img/a2.jpg"></a>
		                                            <a href="projects.html"><img alt="image" class="img-circle" src="img/a4.jpg"></a>
		                                            <a href="projects.html"><img alt="image" class="img-circle" src="img/a5.jpg"></a>
		                                        </td>
		                                        <td class="project-actions">
		                                            <a class="btn btn-white btn-sm"><i class="fa fa-folder"></i> 查看 </a>
		                                            <a class="btn btn-white btn-sm" onclick="open_from_editor(${obj.serial_id });"><i class="fa fa-pencil"></i> 编辑 </a>
		                                        </td>
		                                    </tr>
                                	</c:forEach>
                                </tbody>
                            </table>

	                            <br>
	                            <div class="btn-group">
	                                <button type="button" class="btn btn-white"><i class="fa fa-chevron-left"></i>
	                                </button>
	                              	<c:forEach begin="1"  end="${ bloglist.totalPage}"  varStatus="i">
		                                <button id="btn_${i.index }" onclick="getBlogPageInInt(${i.index })" class="btn btn-primary ${i.index==1 ? 'btn-primary ': 'btn-white' }">${i.index }</button>
	                              	</c:forEach>
	                                <button type="button" class="btn btn-white">
	                                		<i class="fa fa-chevron-right"></i>
	                                </button>
	                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
         <div class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog"  aria-hidden="true" >
             <div class="modal-dialog modal-sm" style="width:80%;height;auto">
                 <div class="modal-content">
                     <div class="modal-header" style="padding:15px 15px">
                         <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                         <h4 class="modal-title">撰写博文</h4>
                         <!-- <small class="font-bold">这里可以显示副标题。</small> -->
                     </div>
                     <div class="modal-body gray-bg" style="padding:0px">
                     	<div class="ibox-content gray-bg" style="padding:0px" > 
					  			<jsp:include page="bac_blog_push.jsp"></jsp:include>
							 <form class="form-horizontal m-t" id="pushBlogForm" >
<%-- 					  			<jsp:include page="form_editors.jsp"></jsp:include> --%>
					  		</form>                      
						</div>
                     </div>
		            <div class="modal-footer">
		                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
		                <button type="button" class="btn btn-primary">保存</button>
		            </div>
                 </div>
             </div>
         </div>
	</div>
    

    <!-- 自定义js -->
    <script src="js/content.js"></script>

	<!-- SUMMERNOTE -->
    <script src="../plugins/summernote/summernote.min.js"></script>
    <script src="../plugins/summernote/summernote-zh-CN.js"></script>

    <script>
        $(document).ready(function () {

            $('.summernote').summernote({
                lang: 'zh-CN',
                height:200
            });
            $('#loading-example-btn').click(function () {
                btn = $(this);
                simpleLoad(btn, true)
                simpleLoad(btn, false)
            });

        });

        function simpleLoad(btn, state) {
            if (state) {
                btn.children().addClass('fa-spin');
                btn.contents().last().replaceWith(" Loading");
            } else {
                setTimeout(function () {
                    btn.children().removeClass('fa-spin');
                    btn.contents().last().replaceWith(" Refresh");
                }, 2000);
            }
        }
        var edit = function () {
            $("#eg").addClass("no-padding");
            $('.click2edit').summernote({
                lang: 'zh-CN',
                focus: true
            });
        };
        var save = function () {
            $("#eg").removeClass("no-padding");
            var aHTML = $('.click2edit').code(); //save HTML If you need(aHTML: array).
            $('.click2edit').destroy();
        };
        
        function getBlogPageInInt(pageNum) {
	         alert(pageNum);
	         
	         //var ss = $(".btn .btn-primary .btn-primary ").;
	         
	         alert(ss);
	         
	         
	    }
    </script>

    <script>

        
        
        
        
    </script>
    </body>
</html>